﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Management_MedicalDirector_Giuongbenh : System.Web.UI.Page
{
    public static string idTotal = "";
    public static Color defautColor;

    protected void giuongbenh_click(object sender, EventArgs e)
    {
        string id = (sender as LinkButton).CommandArgument;
        idTotal = id;
        String idward1="";
        SqlConnection con = new SqlConnection(GlobalConstant.CONNECTION_STRING);
        con.Open();
        string sql = "SELECT * FROM tbBed WHERE ID=" + id;
        SqlCommand cmd = new SqlCommand(sql, con);
        SqlDataReader reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            txtIDRoom.Text = reader.GetInt32(1).ToString();
            txtBedname.Text = reader.GetString(2).ToString();    
        }    
        con.Close();
        con.Open();
        sql="SELECT * FROM tbRoom WHERE ID='" +txtIDRoom.Text+"'";
        cmd = new SqlCommand(sql, con);
        reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            idward1 = reader.GetInt32(1).ToString();
            txtRoomName.Text = reader.GetString(2);
            //txtWard
        }
        con.Close();
        con.Open();
        sql = "SELECT * FROM tbWard WHERE ID='" + idward1 + "'";
        cmd = new SqlCommand(sql, con);
        reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            
            txtward.Text = reader.GetString(1);
            //txtWard
        }
        con.Close();
    }      
}